%it returns vectors for each density
% c clustering coefficient
% e efficiency
% c_w random rewiered network clustering coefficient
% e_w random rewiered network efficiency
% sw small-wolrd index
% connected if connected

function [res]=thresholdAnalysis(M,density,nSurr)

nch=length(M);
connected=0;
nEdge=0;
c=0;
e=0;
c_w=0;
e_w=0;
sw=0;


thM=threshold_proportional(M,density);
thM(thM>0)=1;
    
[disc,pred,cl] =graphtraverse(sparse(thM),1,'METHOD','DFS','DIRECTED',false);
    
if(length(disc)==nch)
    connected=1;
end
    
nEdge=sum(sum(tril(thM,-1)));
[c,e]=graphMeasure_Bin(thM);
[c_w,e_w]=surrogateNetConnected(thM,nSurr);
    
if((c/c_w)>1)
    sw=(c/c_w)/((e/e_w));   
 end    

res=[c,e,c_w,e_w,sw,connected,nEdge];

